package com.jpa.lgt.dao;

import com.jpa.lgt.entity.HomeDevice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;


public interface HomeDeviceRepository extends JpaRepository<HomeDevice, Long>, JpaSpecificationExecutor<HomeDevice> {

    @Query("select hd from HomeDevice hd where hd.deviceType.deviceTypeId=?1")
    List<HomeDevice> queryDeviceByDeviceTypeId(Integer deviceTypeId);

    @Query("select hd.deviceName as deviceName, hd.deviceType.deviceTypeName as deviceTypeName from HomeDevice as hd where hd.deviceType.deviceTypeId=?1")
    List<Map<String,Object>> queryByDeviceId(Integer deviceTypeId);
}
